home *** CD-ROM | disk | FTP | other *** search
Wrap
// Copyright (C) 1997-2002 Alias|Wavefront, // a division of Silicon Graphics Limited. // // The information in this file is provided for the exclusive use of the // licensees of Alias|Wavefront. Such users have the right to use, modify, // and incorporate this code into other products for purposes authorized // by the Alias|Wavefront license agreement, without fee. // // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. // // // Alias|Wavefront Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: October 21st 1997 // Author: antoine // // // Procedure Name: // distributedRenderSession // // Description: // distributedRenderSession: Sets the working directory and saves // a temporary scene to be used by the dispatcher. // // Input Arguments: // None. // // Return Value: // None. // // Procedure Name: // startDistributedRender // // Description: // startDistributedRender: call dispatcher with the good arguments. // // Input Arguments: // The temporary scene file name. // The file type. // // Return Value: // true upon success. // global string $dispatcherConfigPath = "/etc/config/dispatcher.home"; global string $dispatcherExecutableName = "dispatcher"; global string $dispatcherPath = ""; global proc int findDispatcherPath() { global string $dispatcherConfigPath; global string $dispatcherExecutableName; global string $dispatcherPath; $dispatcherPath=""; if(file("-q", "-exists", $dispatcherConfigPath)) { // this course is safer because the link to the dispatcher binary // may not be installed in /usr/sbin or /sbin. // For NT, I guess we'll have to probe the default binary location.. string $dispatcherHome = `system("echo -n `cat " + $dispatcherConfigPath + "`")`; $dispatcherPath = $dispatcherHome + "/" + $dispatcherExecutableName; if(! file("-q","-exists", $dispatcherPath)) $dispatcherPath=""; } if(size($dispatcherPath) == 0) { error("startDistributedRender: please ask your system manager to install dispatcher\nor refer to URL file:/usr/aw/COM/doc/dispatcher_html/DispatcherExpert.doc.html"); return false; } return true; } global proc distributedRenderSession() { if(findDispatcherPath()) { string $workspace = `workspace -q -fn`; setWorkingDirectory $workspace "mayaBinary" "scene"; fileBrowser startDistributedRender "Save/Render" mayaBinary 1; } } global proc int startDistributedRender ( string $fileName, string $fileType ) { if (`about -evalVersion`) { error("startDistributedRender: Distributed rendering is not supported\n"+ "by the Personal Learning Edition of Maya."); return false; } if(findDispatcherPath()) { global string $dispatcherPath; // // Save the file. // string $renderFile = `file -ea -typ $fileType $fileName`; // // Run the dispatchMayaRenderScript... // if( size($renderFile) > 0 && file("-q", "-exists", $renderFile)) { // // Get the render globals. // string $glob[] = `ls -rg`; if( size($glob) > 0 && size($glob[0]) > 0 ) { int $anim = `getAttr ($glob[0]+".animation")`; int $range = `getAttr ($glob[0]+".animationRange")`; int $start, $end; // // Get the animation range (from the render globals or from the // range controler). // if( $anim == 1 && $range == 0 ) { $start = `getAttr ($glob[0]+".startFrame")`; $end = `getAttr ($glob[0]+".endFrame")`; } else { $start = `playbackOptions -q -minTime`; $end = `playbackOptions -q -maxTime`; } // // Build the job name based on the script file name. // string $list[]; int $n = tokenize( $renderFile, "/", $list ); string $jobName = $list[$n-1]; // // Get the root project path. // string $rootDir = `workspace -q -rd`; // // Execute the command in background (i.e redirect the outputs). // It calls dispatcher with the following arguments: // // -n $start $end 10 // animation range to be computed // // 10 is the default number of images // // to be computed on a per job basis. // -g // dispatcher comes up in gui mode to // // edit the job parameters. // -j string // Job name. // -c command // command to execute. // string $command = ($dispatcherPath + " -n "+$start+" "+$end+" 10 -g -j "+$jobName+" -c \"dispatch_maya_render # "+$end+" 10 -proj "+$rootDir+" "+$renderFile+"\" >/dev/null 2>&1 &"); system( $command ); string $currentDir = `workspace -q -dir`; retainWorkingDirectory( $currentDir ); return true; } } else error("startDistributedRender: no renderable scene given"); } return false; }